/**
 * 
 */
package badugi;

import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.List;

import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

/**
 * @author aleks
 *
 */
public class WhoWonTest {

	private Room rom;
	private Pack myPack;
	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
		rom = new Room(3,10,2,4);
		myPack = new Pack();
		//rom.run();
	}

	/**
	 * @throws java.lang.Exception
	 */
	@After
	public void tearDown() throws Exception {
	}

	@Ignore
	@Test
	public void test() {
		myPack.shufflePack();
		ArrayList<Card> myPackNow = myPack.getPack();
		Hand myHand1 = new Hand(myPack.giveMeOneCard(), myPack.giveMeOneCard(), myPack.giveMeOneCard(), myPack.giveMeOneCard());
		Hand myHand2 = new Hand(myPack.giveMeOneCard(), myPack.giveMeOneCard(), myPack.giveMeOneCard(), myPack.giveMeOneCard());
		Hand[] allHands = new Hand[2];
		allHands[0] = myHand1;
		allHands[1] = myHand2;
		System.out.println("Hand[0]: " + myHand1.toString());
		System.out.println("Hand[1]: " + myHand2.toString());
		int who = WhoWon.CheckWhoWon(allHands);
		System.out.println("Won:  " + who);
		//who = WhoWon.CheckWhoWon(myHand1, myHand2);
		//System.out.println("Won (old method):  " + who);
		

	}

	@Test
	public void testOfFour() {
		myPack.shufflePack();
		Hand[] allHands = new Hand[4];
		for (int i = 0; i < allHands.length; i++) {
			allHands[i] = new Hand(myPack.giveMeOneCard(), myPack.giveMeOneCard(), myPack.giveMeOneCard(), myPack.giveMeOneCard());
		}
		for (Hand item: allHands) {
			item.sortHand();
			System.out.println(item);
		}
		int who = WhoWon.CheckWhoWon(allHands);
		System.out.println("Won:  " + who);
	}
	
	@Test
	public void testOfFourWithADraw() throws Exception {
		myPack.shufflePack();
		Hand[] allHands = new Hand[4];
		allHands[0] = new Hand(new Card(1,1), new Card(2,2), new Card(2,7), new Card(2,5));
		allHands[1] = new Hand(new Card(2,1), new Card(1,2), new Card(1,4), new Card(1,11));
		allHands[2] = new Hand(new Card(3,1), new Card(4,2), new Card(3,4), new Card(4,9));
		allHands[3] = new Hand(new Card(4,1), new Card(3,2), new Card(3,5), new Card(3,12));
		int who = WhoWon.CheckWhoWon(allHands);
		System.out.println("Won: " + who);
	}
	
	@Ignore
	@Test
	public void testWhichIsTheMostImportant() throws Exception {
		Hand[] allHands = new Hand[2];
		allHands[0] = new Hand(new Card(2,11), new Card(3,11), new Card(4,11), new Card(2,12));
		allHands[1] = new Hand(new Card(1,4), new Card(2,4), new Card(3,4), new Card(1,11));
		int who = WhoWon.CheckWhoWon(allHands);
		System.out.println("Won: " + who);
	}
	
	@Test
	public void testMakeMeARankFromString() {
		String a = WhoWon.makeMeARankFromString("1,7/4,11/1,9/2,9");
	}

}
